\subsection{\refactoring{Inline Constant}}
This refactoring inlines a constant field into all its uses. Implemented in \sourcelink{InlineTemp/InlineConstant.jrag}; see Algorithms~\ref{alg:InlineConstant-1}, \ref{alg:InlineConstant-2}, \ref{alg:RemoveField}.

\begin{algorithm}[p]
\caption{$\refactoring{Inline Constant}(f : \type{Field})$}
\label{alg:InlineConstant-1}
\begin{algorithmic}[1]
\REQUIRE Java $\setminus$ implicit assignment conversion
\ENSURE Java
\medskip
\FORALL{uses $u$ of $f$}
  \STATE $\refactoring{Inline Constant}(u)$
\ENDFOR
\STATE $\refactoring{Remove Field}(f)$
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[p]
\caption{$\refactoring{Inline Constant}(u : \type{FieldAccess})$}
\label{alg:InlineConstant-2}
\begin{algorithmic}[1]
\REQUIRE Java
\ENSURE Java $\cup$ locked dependencies
\medskip
\STATE $f \leftarrow \text{field accessed by $u$}$
\STATE \assert $f$ is \code{final} and \code{static}, and has an initialiser
\STATE $e \leftarrow \text{locked copy of the initialiser of $f$}$
\STATE \assert if $u$ is qualified, then its qualifier is a pure expression
\STATE replace $u$ with $e$, discarding its qualifier if any
\end{algorithmic}
\end{algorithm}

\begin{algorithm}[p]
\caption{$\refactoring{Remove Field}(f : \type{Field})$}
\label{alg:RemoveField}
\begin{algorithmic}[1]
\REQUIRE Java
\ENSURE Java
\medskip
\IF{$f$ is not used and if it has an initialiser, it is pure}
  \STATE remove $f$
\ENDIF
\end{algorithmic}
\end{algorithm}
